/**
    Copyright (c) 2010 ATTi 
    All rights reserved.
    Author: Michael Shu
    Date: 9/29/2010
*/

trigger OpportunityProductCheckForAAS on OpportunityLineItem (before insert,before delete,after delete, after insert,after update) {    
        boolean isUpdate;
        boolean isInsert;
        boolean isDelete;
    if(trigger.isAfter){
        Set<ID> oppIds = new Set<ID>();
        if(trigger.isInsert){
            for(OpportunityLineItem o : trigger.new){
                oppIds.add(o.OpportunityId);
            }
            isInsert = true;
            //AASOpportunityCheck.LockProduct(trigger.newMap,isInsert,isDelete,isUpdate  );
        }else if(trigger.isDelete){
            for(OpportunityLineItem o : trigger.old){
                oppIds.add(o.OpportunityId);
            }
        }else if(trigger.isUpdate){
            isUpdate = true;
            //AASOpportunityCheck.LockProduct(trigger.newMap,isInsert,isDelete,isUpdate  );
        }
        
        if(!oppIds.isEmpty()){
            OppForNatSalesHelperClass.updateProductList(oppIds, null, true);
        }
    }
    if(trigger.isBefore && trigger.isDelete){
        isDelete = true;
       AASOpportunityCheck.LockProduct(trigger.oldMap,isInsert,isDelete,isUpdate  );
            
    }
}